import { IPSCodeList } from '../codelist/ipscode-list';
import { IPSDataEntity } from '../dataentity/ipsdata-entity';
import { IPSDEAction } from '../dataentity/action/ipsdeaction';
import { IPSDEField } from '../dataentity/defield/ipsdefield';
import { IPSDEMainState } from '../dataentity/mainstate/ipsdemain-state';
import { IPSLanguageRes } from '../res/ipslanguage-res';
import { IPSWFDE } from './ipswfde';
import { IPSWorkflow } from './ipsworkflow';
import { PSModelObjectImpl } from '../psmodel-object-impl';

export class PSWFDEImpl extends PSModelObjectImpl implements IPSWFDE {
  get codeName(): string {
    return this.M.codeName;
  }

  get dynaModelFilePath(): string {
    return this.M.dynaModelFilePath;
  }

  protected entitystatepscodelist: IPSCodeList | null = null;

  getEntityStatePSCodeList(): IPSCodeList | null {
    if (this.entitystatepscodelist != null) return this.entitystatepscodelist;
    const value = this.M.getEntityStatePSCodeList;
    if (value == null) {
      return null;
    }
    this.entitystatepscodelist = this.getPSModel4('codelist.IPSCodeList', value, 'getEntityStatePSCodeList') as IPSCodeList;
    return this.entitystatepscodelist;
  }

  get entityStatePSCodeList(): IPSCodeList | null {
    return this.getEntityStatePSCodeList();
  }

  getEntityStatePSCodeListMust(): IPSCodeList {
    const value = this.getEntityStatePSCodeList();
    if (value == null) {
      throw new Error('未指定用户数据状态代码表');
    }
    return value;
  }

  get entityWFCancelState(): string {
    return this.M.entityWFCancelState;
  }

  get entityWFErrorState(): string {
    return this.M.entityWFErrorState;
  }

  get entityWFFinishState(): string {
    return this.M.entityWFFinishState;
  }

  get entityWFState(): string {
    return this.M.entityWFState;
  }

  protected errorpsdemainstate: IPSDEMainState | null = null;

  getErrorPSDEMainState(): IPSDEMainState | null {
    if (this.errorpsdemainstate != null) return this.errorpsdemainstate;
    const value = this.M.getErrorPSDEMainState;
    if (value == null) {
      return null;
    }
    this.errorpsdemainstate = this.getPSDataEntityMust().findPSDEMainState(value);
    return this.errorpsdemainstate;
  }

  get errorPSDEMainState(): IPSDEMainState | null {
    return this.getErrorPSDEMainState();
  }

  getErrorPSDEMainStateMust(): IPSDEMainState {
    const value = this.getErrorPSDEMainState();
    if (value == null) {
      throw new Error('未指定错误跳转主状态');
    }
    return value;
  }

  get extendMode(): 0 | 2 {
    return this.M.extendMode != null ? this.M.extendMode : 0;
  }

  protected finishpsdeaction: IPSDEAction | null = null;

  getFinishPSDEAction(): IPSDEAction | null {
    if (this.finishpsdeaction != null) return this.finishpsdeaction;
    const value = this.M.getFinishPSDEAction;
    if (value == null) {
      return null;
    }
    this.finishpsdeaction = this.getPSDataEntityMust().findPSDEAction(value);
    return this.finishpsdeaction;
  }

  get finishPSDEAction(): IPSDEAction | null {
    return this.getFinishPSDEAction();
  }

  getFinishPSDEActionMust(): IPSDEAction {
    const value = this.getFinishPSDEAction();
    if (value == null) {
      throw new Error('未指定流程完成实体行为');
    }
    return value;
  }

  protected finishpsdemainstate: IPSDEMainState | null = null;

  getFinishPSDEMainState(): IPSDEMainState | null {
    if (this.finishpsdemainstate != null) return this.finishpsdemainstate;
    const value = this.M.getFinishPSDEMainState;
    if (value == null) {
      return null;
    }
    this.finishpsdemainstate = this.getPSDataEntityMust().findPSDEMainState(value);
    return this.finishpsdemainstate;
  }

  get finishPSDEMainState(): IPSDEMainState | null {
    return this.getFinishPSDEMainState();
  }

  getFinishPSDEMainStateMust(): IPSDEMainState {
    const value = this.getFinishPSDEMainState();
    if (value == null) {
      throw new Error('未指定完成跳转主状态');
    }
    return value;
  }

  protected initpsdeaction: IPSDEAction | null = null;

  getInitPSDEAction(): IPSDEAction | null {
    if (this.initpsdeaction != null) return this.initpsdeaction;
    const value = this.M.getInitPSDEAction;
    if (value == null) {
      return null;
    }
    this.initpsdeaction = this.getPSDataEntityMust().findPSDEAction(value);
    return this.initpsdeaction;
  }

  get initPSDEAction(): IPSDEAction | null {
    return this.getInitPSDEAction();
  }

  getInitPSDEActionMust(): IPSDEAction {
    const value = this.getInitPSDEAction();
    if (value == null) {
      throw new Error('未指定流程初始化实体行为');
    }
    return value;
  }

  get memo(): string {
    return this.M.memo;
  }

  protected mywfdatacappslanguageres: IPSLanguageRes | null = null;

  getMyWFDataCapPSLanguageRes(): IPSLanguageRes | null {
    if (this.mywfdatacappslanguageres != null) return this.mywfdatacappslanguageres;
    const value = this.M.getMyWFDataCapPSLanguageRes;
    if (value == null) {
      return null;
    }
    this.mywfdatacappslanguageres = this.getPSModel4('res.IPSLanguageRes', value, 'getMyWFDataCapPSLanguageRes') as IPSLanguageRes;
    return this.mywfdatacappslanguageres;
  }

  get myWFDataCapPSLanguageRes(): IPSLanguageRes | null {
    return this.getMyWFDataCapPSLanguageRes();
  }

  getMyWFDataCapPSLanguageResMust(): IPSLanguageRes {
    const value = this.getMyWFDataCapPSLanguageRes();
    if (value == null) {
      throw new Error('未指定我的数据标题语言资源');
    }
    return value;
  }

  get myWFDataCaption(): string {
    return this.M.myWFDataCaption;
  }

  protected mywfworkcappslanguageres: IPSLanguageRes | null = null;

  getMyWFWorkCapPSLanguageRes(): IPSLanguageRes | null {
    if (this.mywfworkcappslanguageres != null) return this.mywfworkcappslanguageres;
    const value = this.M.getMyWFWorkCapPSLanguageRes;
    if (value == null) {
      return null;
    }
    this.mywfworkcappslanguageres = this.getPSModel4('res.IPSLanguageRes', value, 'getMyWFWorkCapPSLanguageRes') as IPSLanguageRes;
    return this.mywfworkcappslanguageres;
  }

  get myWFWorkCapPSLanguageRes(): IPSLanguageRes | null {
    return this.getMyWFWorkCapPSLanguageRes();
  }

  getMyWFWorkCapPSLanguageResMust(): IPSLanguageRes {
    const value = this.getMyWFWorkCapPSLanguageRes();
    if (value == null) {
      throw new Error('未指定我的工作标题语言资源');
    }
    return value;
  }

  get myWFWorkCaption(): string {
    return this.M.myWFWorkCaption;
  }

  get name(): string {
    return this.M.name;
  }

  protected psdataentity: IPSDataEntity | null = null;

  getPSDataEntity(): IPSDataEntity | null {
    if (this.psdataentity != null) return this.psdataentity;
    const value = this.M.getPSDataEntity;
    if (value == null) {
      return null;
    }
    this.psdataentity = this.getPSModel4('dataentity.IPSDataEntity', value, 'getPSDataEntity') as IPSDataEntity;
    return this.psdataentity;
  }

  get psDataEntity(): IPSDataEntity | null {
    return this.getPSDataEntity();
  }

  getPSDataEntityMust(): IPSDataEntity {
    const value = this.getPSDataEntity();
    if (value == null) {
      throw new Error('未指定实体对象');
    }
    return value;
  }

  protected psworkflow: IPSWorkflow | null = null;

  getPSWorkflow(): IPSWorkflow | null {
    if (this.psworkflow != null) return this.psworkflow;
    const value = this.M.getPSWorkflow;
    if (value == null) {
      return null;
    }
    this.psworkflow = this.getPSModel4('wf.IPSWorkflow', value, 'getPSWorkflow') as IPSWorkflow;
    return this.psworkflow;
  }

  get psWorkflow(): IPSWorkflow | null {
    return this.getPSWorkflow();
  }

  getPSWorkflowMust(): IPSWorkflow {
    const value = this.getPSWorkflow();
    if (value == null) {
      throw new Error('未指定工作流对象');
    }
    return value;
  }

  protected pwfinstpsdefield: IPSDEField | null = null;

  getPWFInstPSDEField(): IPSDEField | null {
    if (this.pwfinstpsdefield != null) return this.pwfinstpsdefield;
    const value = this.M.getPWFInstPSDEField;
    if (value == null) {
      return null;
    }
    this.pwfinstpsdefield = this.getPSDataEntityMust().findPSDEField(value);
    return this.pwfinstpsdefield;
  }

  get pWFInstPSDEField(): IPSDEField | null {
    return this.getPWFInstPSDEField();
  }

  getPWFInstPSDEFieldMust(): IPSDEField {
    const value = this.getPWFInstPSDEField();
    if (value == null) {
      throw new Error('未指定父流程实例属性');
    }
    return value;
  }

  protected processpsdemainstate: IPSDEMainState | null = null;

  getProcessPSDEMainState(): IPSDEMainState | null {
    if (this.processpsdemainstate != null) return this.processpsdemainstate;
    const value = this.M.getProcessPSDEMainState;
    if (value == null) {
      return null;
    }
    this.processpsdemainstate = this.getPSDataEntityMust().findPSDEMainState(value);
    return this.processpsdemainstate;
  }

  get processPSDEMainState(): IPSDEMainState | null {
    return this.getProcessPSDEMainState();
  }

  getProcessPSDEMainStateMust(): IPSDEMainState {
    const value = this.getProcessPSDEMainState();
    if (value == null) {
      throw new Error('未指定处理中主状态');
    }
    return value;
  }

  protected proxydatapsdefield: IPSDEField | null = null;

  getProxyDataPSDEField(): IPSDEField | null {
    if (this.proxydatapsdefield != null) return this.proxydatapsdefield;
    const value = this.M.getProxyDataPSDEField;
    if (value == null) {
      return null;
    }
    this.proxydatapsdefield = this.getPSDataEntityMust().findPSDEField(value);
    return this.proxydatapsdefield;
  }

  get proxyDataPSDEField(): IPSDEField | null {
    return this.getProxyDataPSDEField();
  }

  getProxyDataPSDEFieldMust(): IPSDEField {
    const value = this.getProxyDataPSDEField();
    if (value == null) {
      throw new Error('未指定代理数据存储属性');
    }
    return value;
  }

  protected proxymodulepsdefield: IPSDEField | null = null;

  getProxyModulePSDEField(): IPSDEField | null {
    if (this.proxymodulepsdefield != null) return this.proxymodulepsdefield;
    const value = this.M.getProxyModulePSDEField;
    if (value == null) {
      return null;
    }
    this.proxymodulepsdefield = this.getPSDataEntityMust().findPSDEField(value);
    return this.proxymodulepsdefield;
  }

  get proxyModulePSDEField(): IPSDEField | null {
    return this.getProxyModulePSDEField();
  }

  getProxyModulePSDEFieldMust(): IPSDEField {
    const value = this.getProxyModulePSDEField();
    if (value == null) {
      throw new Error('未指定代理模块存储属性');
    }
    return value;
  }

  protected udstatepsdefield: IPSDEField | null = null;

  getUDStatePSDEField(): IPSDEField | null {
    if (this.udstatepsdefield != null) return this.udstatepsdefield;
    const value = this.M.getUDStatePSDEField;
    if (value == null) {
      return null;
    }
    this.udstatepsdefield = this.getPSDataEntityMust().findPSDEField(value);
    return this.udstatepsdefield;
  }

  get uDStatePSDEField(): IPSDEField | null {
    return this.getUDStatePSDEField();
  }

  getUDStatePSDEFieldMust(): IPSDEField {
    const value = this.getUDStatePSDEField();
    if (value == null) {
      throw new Error('未指定用户状态属性');
    }
    return value;
  }

  get userCat(): string {
    return this.M.userCat;
  }

  get userTag(): string {
    return this.M.userTag;
  }

  get userTag2(): string {
    return this.M.userTag2;
  }

  get userTag3(): string {
    return this.M.userTag3;
  }

  get userTag4(): string {
    return this.M.userTag4;
  }

  protected wfactorspsdefield: IPSDEField | null = null;

  getWFActorsPSDEField(): IPSDEField | null {
    if (this.wfactorspsdefield != null) return this.wfactorspsdefield;
    const value = this.M.getWFActorsPSDEField;
    if (value == null) {
      return null;
    }
    this.wfactorspsdefield = this.getPSDataEntityMust().findPSDEField(value);
    return this.wfactorspsdefield;
  }

  get wFActorsPSDEField(): IPSDEField | null {
    return this.getWFActorsPSDEField();
  }

  getWFActorsPSDEFieldMust(): IPSDEField {
    const value = this.getWFActorsPSDEField();
    if (value == null) {
      throw new Error('未指定流程操作者属性');
    }
    return value;
  }

  protected wfinstpsdefield: IPSDEField | null = null;

  getWFInstPSDEField(): IPSDEField | null {
    if (this.wfinstpsdefield != null) return this.wfinstpsdefield;
    const value = this.M.getWFInstPSDEField;
    if (value == null) {
      return null;
    }
    this.wfinstpsdefield = this.getPSDataEntityMust().findPSDEField(value);
    return this.wfinstpsdefield;
  }

  get wFInstPSDEField(): IPSDEField | null {
    return this.getWFInstPSDEField();
  }

  getWFInstPSDEFieldMust(): IPSDEField {
    const value = this.getWFInstPSDEField();
    if (value == null) {
      throw new Error('未指定流程实例属性');
    }
    return value;
  }

  get wFMode(): string {
    return this.M.wFMode;
  }

  get wFProxyMode(): 0 | 1 | 2 {
    return this.M.wFProxyMode;
  }

  protected wfretpsdefield: IPSDEField | null = null;

  getWFRetPSDEField(): IPSDEField | null {
    if (this.wfretpsdefield != null) return this.wfretpsdefield;
    const value = this.M.getWFRetPSDEField;
    if (value == null) {
      return null;
    }
    this.wfretpsdefield = this.getPSDataEntityMust().findPSDEField(value);
    return this.wfretpsdefield;
  }

  get wFRetPSDEField(): IPSDEField | null {
    return this.getWFRetPSDEField();
  }

  getWFRetPSDEFieldMust(): IPSDEField {
    const value = this.getWFRetPSDEField();
    if (value == null) {
      throw new Error('未指定嵌入流程返回值存放属性');
    }
    return value;
  }

  get wFStartName(): string {
    return this.M.wFStartName;
  }

  protected wfstatepsdefield: IPSDEField | null = null;

  getWFStatePSDEField(): IPSDEField | null {
    if (this.wfstatepsdefield != null) return this.wfstatepsdefield;
    const value = this.M.getWFStatePSDEField;
    if (value == null) {
      return null;
    }
    this.wfstatepsdefield = this.getPSDataEntityMust().findPSDEField(value);
    return this.wfstatepsdefield;
  }

  get wFStatePSDEField(): IPSDEField | null {
    return this.getWFStatePSDEField();
  }

  getWFStatePSDEFieldMust(): IPSDEField {
    const value = this.getWFStatePSDEField();
    if (value == null) {
      throw new Error('未指定流程状态属性');
    }
    return value;
  }

  protected wfsteppscodelist: IPSCodeList | null = null;

  getWFStepPSCodeList(): IPSCodeList | null {
    if (this.wfsteppscodelist != null) return this.wfsteppscodelist;
    const value = this.M.getWFStepPSCodeList;
    if (value == null) {
      return null;
    }
    this.wfsteppscodelist = this.getPSModel4('codelist.IPSCodeList', value, 'getWFStepPSCodeList') as IPSCodeList;
    return this.wfsteppscodelist;
  }

  get wFStepPSCodeList(): IPSCodeList | null {
    return this.getWFStepPSCodeList();
  }

  getWFStepPSCodeListMust(): IPSCodeList {
    const value = this.getWFStepPSCodeList();
    if (value == null) {
      throw new Error('未指定流程步骤代码表');
    }
    return value;
  }

  protected wfsteppsdefield: IPSDEField | null = null;

  getWFStepPSDEField(): IPSDEField | null {
    if (this.wfsteppsdefield != null) return this.wfsteppsdefield;
    const value = this.M.getWFStepPSDEField;
    if (value == null) {
      return null;
    }
    this.wfsteppsdefield = this.getPSDataEntityMust().findPSDEField(value);
    return this.wfsteppsdefield;
  }

  get wFStepPSDEField(): IPSDEField | null {
    return this.getWFStepPSDEField();
  }

  getWFStepPSDEFieldMust(): IPSDEField {
    const value = this.getWFStepPSDEField();
    if (value == null) {
      throw new Error('未指定流程步骤属性');
    }
    return value;
  }

  protected wfverpsdefield: IPSDEField | null = null;

  getWFVerPSDEField(): IPSDEField | null {
    if (this.wfverpsdefield != null) return this.wfverpsdefield;
    const value = this.M.getWFVerPSDEField;
    if (value == null) {
      return null;
    }
    this.wfverpsdefield = this.getPSDataEntityMust().findPSDEField(value);
    return this.wfverpsdefield;
  }

  get wFVerPSDEField(): IPSDEField | null {
    return this.getWFVerPSDEField();
  }

  getWFVerPSDEFieldMust(): IPSDEField {
    const value = this.getWFVerPSDEField();
    if (value == null) {
      throw new Error('未指定流程版本存放属性');
    }
    return value;
  }

  protected workflowpsdefield: IPSDEField | null = null;

  getWorkflowPSDEField(): IPSDEField | null {
    if (this.workflowpsdefield != null) return this.workflowpsdefield;
    const value = this.M.getWorkflowPSDEField;
    if (value == null) {
      return null;
    }
    this.workflowpsdefield = this.getPSDataEntityMust().findPSDEField(value);
    return this.workflowpsdefield;
  }

  get workflowPSDEField(): IPSDEField | null {
    return this.getWorkflowPSDEField();
  }

  getWorkflowPSDEFieldMust(): IPSDEField {
    const value = this.getWorkflowPSDEField();
    if (value == null) {
      throw new Error('未指定工作流存放属性');
    }
    return value;
  }

  get defaultMode(): boolean {
    return this.M.defaultMode;
  }

  get enableUserStart(): boolean {
    return this.M.enableUserStart;
  }

  get useWFProxyApp(): boolean {
    return this.M.useWFProxyApp;
  }

  get cls(): string {
    return 'PSWFDEImpl';
  }

  instanceof(cls: string): boolean {
    if (cls == 'dataentity.wf.IPSDEWF' || cls == 'wf.IPSWFDE') return true;
    return super.instanceof(cls);
  }
}
